package com.cn.dim.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import javax.transaction.Transactional;

import org.springframework.stereotype.Service;

import com.cn.dim.dao.DepDao;
import com.cn.dim.pojo.Dep;
import com.cn.dim.service.DepService;
import com.github.pagehelper.PageHelper;
@Service("depService")
public class DepServiceImpl implements DepService{
	@Resource
	DepDao depDao;
	@Override
	public List<Map<String, Object>> queryDep(Map<String, Object> m) {
		// TODO Auto-generated method stub
		PageHelper.startPage(Integer.valueOf(m.get("pageIndex").toString()),Integer.valueOf(m.get("pageSize").toString()),true);
		return depDao.queryDep(m);
	}
	@Override
	@Transactional
	public int insertDep(Dep d,List<Map<String,Object>> list) {
		// TODO Auto-generated method stub
		depDao.insertDep(d);
		return depDao.insertDepRPosition(list);
	}
	@Override
	public List<Map<String, Object>> queryDepByLevel1(Map<String, Object> m) {
		// TODO Auto-generated method stub
		return depDao.queryDepByLevel1(m);
	}
	@Override
	public List<Dep> queryDepartmentList(Map<String, Object> m) {
		// TODO Auto-generated method stub
		return depDao.queryDepartmentList(m);
	}
	@Override
	public Dep queryDepBeanById(Map<String, Object> m) {
		// TODO Auto-generated method stub
		return depDao.queryDepBeanById(m);
	}
	@Override
	public List<Map<String, Object>> queryDepAndPosition(Map<String, Object> m) {
		// TODO Auto-generated method stub
		return depDao.queryDepAndPosition(m);
	}
	@Override
	public List<Map<String, Object>> checkChild(Map<String, Object> m) {
		// TODO Auto-generated method stub
		return depDao.checkChild(m);
	}
	@Override
	@Transactional
	public int delDep(Map<String,Object> m) {
		// TODO Auto-generated method stub
		depDao.delDepAndpos(m);
		depDao.delUser_Dep_Pos(m);
		return depDao.delDep(m);
	}
	@Override
	public int updateDep(Dep d,List<Map<String, Object>> list) {
		// TODO Auto-generated method stub
		Map<String,Object> m = new HashMap<>();
		m.put("id", d.getId());
		depDao.delDepAndposByid(m);
		depDao.updateDep(d);
		return depDao.insertDepRPosition(list);
	}


}
